<# # It is recommended to test the script on a local machine for its purpose and effects. # ManageEngine Endpoint Central will not be responsible for any # damage/loss to the data/setup based on the behavior of the script. # Description - Script to Change DNS Primary and Secondary IP Address , Kindly Make sure that the interface name exists in the machine # Parameters - "Connection Name" "Primary IP Address" "Secondary IP Address" # Configuration Type - COMPUTER # Note - Connection Name is case sensitive #> $dnsServers=Get-NetIPConfiguration | Select -ExpandProperty interfaceAlias $interfaceName = $args[0] $prIp= $args[1] $secIp= $args[2] $count = 0 foreach($dnsServer in $dnsServers) { if($interfaceName -eq $dnsServer) { Set-DNSClientServerAddress -interfacealias $dnsServer -ServerAddresses ($prIp,$secIp) $count = 1 } } if($count -eq 0) { Write-Host "No interface found with the name" Write-Host "Check whether the connection name exits" }